'''
Created on 27/09/2012

@author: u346156
'''
import unittest

from Structural_Model.DataStream import *
from Structural_Model.DataStreamFromFile import *

class Test(unittest.TestCase):


    def setUp(self):
        pass


    def tearDown(self):
        pass


    def testSingleRecordFile(self):
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileSingleTest.txt", "Tests/StructuralModelSingleTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "NothingxmlwhatxmlhtmlnewhtmlNothing"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileSingleTest.txt", "Tests/StructuralModelTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "NothingxmlwhatxmlhtmlnewhtmlNothing"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileSingleTest.txt", "Tests/StructuralModelSingleStartTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "Nothing"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileSingleTest.txt", "Tests/StructuralModelSingleEndTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "xmlwhatxmlhtmlnewhtmlNothing"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))
        
    
    def testMultipleRecordFileStart(self):
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileMultipleStartTest.txt", "Tests/StructuralModelSingleStartTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "Nothingxmlwhatxmlhtmlnewhtml"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))
    
    def testMultipleRecordFileEnd(self):
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileMultipleEndTest.txt", "Tests/StructuralModelSingleEndTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "xmlwhatxmlhtmlnewhtmlNothing"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))
    
    def testMultipleRecordFileStartandEnd(self):
        self.dataStreamFile = DataStreamFromFile("Tests/DataStreamFileMultipleStartandEndTest.txt", "Tests/StructuralModelTest.xml")
        self.dataStream = self.dataStreamFile.getDataStream().getRecord()
        data = "NothingxmlwhatxmlhtmlnewhtmlNothing"
        self.assertTrue(self.dataStream == data, "Failure expected {0} got {1}".format(data, self.dataStream))


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testSingleRecordFile']
    unittest.main()